#!/usr/bin/env python


def insert_sort(nums):
    for i in range(1, len(nums)):
        tmp = nums[i]

        pos = i
        while pos > 0 and nums[pos - 1] > tmp:
            nums[pos] = nums[pos - 1]
            pos -= 1

        nums[pos] = tmp
    
    return nums


if __name__ == "__main__":
    import random

    nums = [random.randint(0, 100) for _ in range(20)]
    print(nums)
    print(insert_sort(nums))